home *** CD-ROM | disk | FTP | other *** search
/ PCGUIA 117 / PC Guia 117.iso / Software / Produtividade / Software3 / Product4 / Data1.cab / _4795289C828C44C38B767B332455F4CD < prev    next >
Encoding:
Text File  |  2004-10-19  |  9.7 KB  |  281 lines

  1. /*******************************************************************/
  2. /*                                                                 */
  3. /*                      ADOBE CONFIDENTIAL                         */
  4. /*                   _ _ _ _ _ _ _ _ _ _ _ _ _                     */
  5. /*                                                                 */
  6. /* Copyright 2004 Adobe Systems Incorporated                       */
  7. /* All Rights Reserved.                                            */
  8. /*                                                                 */
  9. /* NOTICE:  All information contained herein is, and remains the   */
  10. /* property of Adobe Systems Incorporated and its suppliers, if    */
  11. /* any.  The intellectual and technical concepts contained         */
  12. /* herein are proprietary to Adobe Systems Incorporated and its    */
  13. /* suppliers and may be covered by U.S. and Foreign Patents,       */
  14. /* patents in process, and are protected by trade secret or        */
  15. /* copyright law.  Dissemination of this information or            */
  16. /* reproduction of this material is strictly forbidden unless      */
  17. /* prior written permission is obtained from Adobe Systems         */
  18. /* Incorporated.                                                   */
  19. /*                                                                 */
  20. /*******************************************************************/
  21.  
  22.  
  23. /*
  24. **-----------------------------------------------------------------------------
  25. ** Effect File Variables
  26. **-----------------------------------------------------------------------------
  27. */
  28.  
  29. uniform float4x4    gWorldViewProj : WorldViewProjection; // This matrix will be loaded by the application
  30. uniform float4x4    gWorldViewInverse;
  31. uniform float4x4    gWorldView;
  32. uniform float4        gLightPosition;
  33. uniform float4        gLightColor = float4(0.8,0.8,0.8,1.0);
  34. uniform float        gCurrentParameter;
  35. uniform float        gAspectRatio;
  36. uniform float        gPAR;
  37. uniform float        gTranslateX;
  38. uniform float        gTranslateY;
  39. uniform float4        gEyePosition;
  40. uniform float        gPI;
  41. texture                gVideoTexture;
  42.  
  43. uniform float4        gC1;
  44. uniform float4        gC2;
  45. uniform float4        gC3;
  46. uniform float4        gC4;
  47. uniform float4        gC5;
  48. uniform float4        gC6;
  49. uniform float4        gC7;
  50. uniform float4        gC8;
  51. uniform float4        gC9;
  52. uniform float        dir;
  53.  
  54. /*
  55. **-----------------------------------------
  56. **        Sampler States
  57. **-----------------------------------------
  58. */
  59. //incoming video texture
  60. sampler Sampler = sampler_state
  61. {
  62.     Texture   = (gVideoTexture);
  63.     MipFilter = LINEAR;
  64.     MinFilter = LINEAR;
  65.     MagFilter = LINEAR;
  66. };
  67.  
  68. /*
  69. **-----------------------------------------------------------------------------
  70. ** Vertex Definitions
  71. **-----------------------------------------------------------------------------
  72. ** APP_OUTPUT is the structure in which we receive the vertices from the application
  73. */
  74. struct APP_OUTPUT
  75. {
  76.     float3 mPosition    : POSITION;
  77.     float3 mNormal        : NORMAL;
  78.     float2 mTexCoord    : TEXCOORD0;
  79.     
  80. };
  81.  
  82. /* 
  83. ** Pixel Shader structure declaration (For Foreground mesh)
  84. */
  85.  
  86. struct VS_OUTPUT 
  87. {
  88.   float4 mHPosition        : POSITION;        // coord position in window
  89.   float2 mTexcoord        : TEXCOORD0;    // wavy or fleck map texture coordinates
  90.   float3 mLightVec        : TEXCOORD1;    // position of light relative to point
  91.   float3 mHalfVec        : TEXCOORD2;    // Blinn halfangle
  92.   float3 mNormal        : TEXCOORD3;
  93. };
  94.  
  95. /* 
  96. ** Pixel Shader structure declaration (For Background Mesh)
  97. */
  98. struct PLAIN_VS_OUTPUT 
  99. {
  100.     float4 mHPosition        : POSITION;        // coord position in window
  101.     float2 mTexcoord        : TEXCOORD0;    // texture coordinates
  102. };
  103.  
  104. /*
  105. ** TEMP_OUT is a temporary structure for the DoSphereCurl function
  106. */
  107. struct TEMP_OUT
  108. {
  109.     float4 mPosition    : POSITION;
  110.     float3 mNormal        : NORMAL0;
  111. };
  112.  
  113. /*
  114. **------------------------------------------------
  115. **        Sphere Morphing Effect
  116. **------------------------------------------------
  117. */
  118. TEMP_OUT DoSphereCurl( float3 position)
  119. {
  120.     TEMP_OUT returnVertex;
  121.     float dist, radius, tempFrameAspectRatio, tempPixelAspectRatio;
  122.     float3 tempVertex;
  123.     
  124.     returnVertex.mPosition = float4(position,1.0f);
  125.     //[NOTE]    ayusman    06/09/2004
  126.     //Use the constants passed from the application to approximate a square to a circle using Quadratic bezier curve.
  127.     //f(u,v) = v*v(gC1*u*u+gC2*u+gC3)+2*v(gC4*u*u+gC5*u+gC6)+(gC7*u*u+gC8*u+gC9) where u,v belongs to [0,1].
  128.     //gC1-gC9 are the constants which are calculated from 8 control points in the application.
  129.     returnVertex.mPosition.xy = float2((position.y*position.y)*((gC1.x)*(position.x*position.x)+(gC2.x)*position.x+gC3.x),(position.y*position.y)*((gC1.y)*(position.x*position.x)+(gC2.y)*position.x+gC3.y));
  130.     returnVertex.mPosition.xy+=float2(((2*position.y)*((gC4.x)*position.x*position.x+(gC5.x)*position.x+(gC6.x))),((2*position.y)*((gC4.y)*position.x*position.x+(gC5.y)*position.x+(gC6.y))));
  131.     returnVertex.mPosition.xy+=float2(((gC7.x)*position.x*position.x+(gC8.x)*position.x+(gC9.x)),((gC7.y)*position.x*position.x+(gC8.y)*position.x+(gC9.y)));
  132.     //translate the model to be centered around the origin
  133.     returnVertex.mPosition.xy -= 0.5f;    
  134.     //Scale it to fit the screen
  135.     returnVertex.mPosition.xy *= 4;
  136.     //Model width = 4 and height = 4. So radius is sqrt(8)= 2.82843
  137.     radius =  2.82843;
  138.     dist = length(returnVertex.mPosition.xy);
  139.     tempVertex = returnVertex.mPosition;
  140.  
  141.     //[NOTE]    ayusman    06/09/2004
  142.     //As we are only approximating a square to a circle, we dont get a perfect circle.
  143.     radius = radius - 0.065;
  144.     if( dist < radius)
  145.     {
  146.         float sinVal, cosVal,theta;
  147.         theta = (dist*gPI)/(radius*2);
  148.         sincos(theta, sinVal, cosVal);
  149.         if(dist != 0.0005)
  150.         {
  151.             tempVertex =  returnVertex.mPosition*radius*sinVal/dist;
  152.         }
  153.         tempVertex.z = -(dir)*radius *cosVal;
  154.     }
  155.     else
  156.     {
  157.         tempVertex =  returnVertex.mPosition*radius/dist;
  158.     }
  159.     returnVertex.mPosition.xyz = lerp(returnVertex.mPosition.xyz, tempVertex, gCurrentParameter);    
  160.     returnVertex.mNormal = lerp(float3(0.0f, 0.0f, dir), (normalize(float3(tempVertex.xy,-tempVertex.z))),  gCurrentParameter);        
  161.     tempFrameAspectRatio = lerp(gAspectRatio,1.0f,gCurrentParameter);
  162.     tempPixelAspectRatio = lerp(1.0f,gPAR,gCurrentParameter);
  163.     returnVertex.mPosition.x*= (tempFrameAspectRatio/tempPixelAspectRatio);
  164.  
  165.     return returnVertex;
  166. }
  167.  
  168. /*
  169. **-------------------------------------------------------------------------
  170. ** Sphere Transition effect - Vertex Shader(For Foreground Mesh)
  171. **-------------------------------------------------------------------------
  172. */
  173. VS_OUTPUT sphere_transition_vs(APP_OUTPUT In)
  174. {
  175.     VS_OUTPUT Out;
  176.  
  177.     // copy texture coordinates
  178.     Out.mTexcoord.xy = In.mTexCoord.xy;
  179.     
  180.     TEMP_OUT tempVertex = DoSphereCurl(float3(In.mPosition.xyz));
  181.     
  182.     // transform vertex position into homogenous clip-space
  183.     Out.mHPosition = mul(gWorldViewProj, tempVertex.mPosition);
  184.     //[NOTE]    ayusman    07/28/2004
  185.     //Translating by a factor to take care of DirectX error which shifts by half pixel
  186.     Out.mHPosition.xy = Out.mHPosition.xy - float2( gTranslateX, -gTranslateY );
  187.     // store light vector
  188.     Out.mLightVec = gLightPosition.xyz;
  189.    
  190.        //compute the half vector    
  191.     Out.mHalfVec = normalize(Out.mLightVec + gEyePosition);
  192.     Out.mHalfVec.z = dot( tempVertex.mNormal, Out.mHalfVec );
  193.     
  194.     //Clamping the normal to [0,1] as ps1.3 clamps vectors to [0,1]
  195.     Out.mNormal = 0.5 * tempVertex.mNormal + 0.5;
  196.     Out.mLightVec = 0.5 * Out.mLightVec + 0.5;
  197.  
  198.     return Out;
  199. }
  200. /*
  201. **-------------------------------------------------------------------------
  202. ** Sphere Transition effect - pixel Shader 1_3(For Foreground Mesh)
  203. **-------------------------------------------------------------------------
  204. */
  205.  
  206. float4 sphere_transition_ps_1_3(VS_OUTPUT In) : COLOR
  207. {   
  208.     float4 outColor, color1;
  209.     float diffuse, specular,ambient=0.20f;
  210.     
  211.     color1 = tex2D( Sampler, In.mTexcoord );
  212.     //Getting back the original normal and LightVector
  213.     In.mNormal = 2 *(In.mNormal - 0.5f);
  214.     In.mLightVec = 2 *(In.mLightVec - 0.5f);
  215.     
  216.     diffuse = dot ( In.mNormal, In.mLightVec );
  217.     specular = In.mHalfVec.z;
  218.     specular *= specular;
  219.     specular *= specular;
  220.     specular *= specular;
  221.     
  222.     outColor.xyz = color1*(diffuse+ambient)+ (specular)*color1*float3(0.45,0.45,0.45);
  223.     outColor.a = color1.a;
  224.     
  225.     return outColor;
  226. }
  227.  
  228. /*
  229. **-------------------------------------------------------------------------
  230. ** Sphere Transition effect - Plain Vertex Shader(For Background Mesh)
  231. **-------------------------------------------------------------------------
  232. */
  233. PLAIN_VS_OUTPUT sphere_transition_vs_plain(APP_OUTPUT In)
  234. {
  235.     PLAIN_VS_OUTPUT Out;
  236.  
  237.     // copy texture coordinates
  238.     Out.mTexcoord.xy = In.mTexCoord.xy;
  239.     
  240.     // transform vertex position into homogenous clip-space
  241.     Out.mHPosition = mul(gWorldViewProj,float4(In.mPosition.x*gAspectRatio,In.mPosition.y,In.mPosition.z,1.0f));
  242.     
  243.     //[NOTE]    ayusman    07/28/2004
  244.     //Translating by a factor to take care of DirectX error which shifts by half pixel
  245.     Out.mHPosition.xy = Out.mHPosition.xy - float2( gTranslateX, -gTranslateY );
  246.   
  247.     return Out;
  248. }
  249.  
  250.  
  251. /*
  252. **-------------------------------------------------------------------------
  253. ** Sphere Transition effect - Plain Pixel Shader 1_3(For Background Mesh)
  254. **-------------------------------------------------------------------------
  255. */
  256.  
  257. float4 sphere_transition_ps_1_3_plain(PLAIN_VS_OUTPUT In) : COLOR
  258. {   
  259.     float4 color1 = tex2D( Sampler, In.mTexcoord );
  260.     return color1;
  261. }
  262.  
  263. technique sphere_transition_1_3
  264. {
  265.     pass Pass0
  266.     {
  267.         //For Background Mesh (SourceB Video)
  268.         Sampler[0] = (Sampler); 
  269.         VertexShader = compile vs_1_1 sphere_transition_vs_plain();
  270.         PixelShader  = compile ps_1_3 sphere_transition_ps_1_3_plain();
  271.         
  272.     }
  273.     pass Pass1
  274.     {
  275.         //For Foreground Mesh (SourceA Video)
  276.         Sampler[0] = (Sampler); 
  277.         VertexShader = compile vs_1_1 sphere_transition_vs();
  278.         PixelShader  = compile ps_1_3 sphere_transition_ps_1_3();
  279.     }
  280. }
  281.